#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int findGCD(vector<int>& nums) {
        int min = INT_MAX;
        int max = INT_MIN;
        for(int x : nums){
            if(x < min){
                min = x;
            }
            if(x > max){
                max = x;
            }
        }

        cout<<max<<","<<min<<endl;
        int remainder;
        while((remainder = max % min ) != 0){
            // int remainder = max % min;
            max = min;
            min = remainder;

            cout<<max<<","<<min<<endl;
        }

        return min;

    }
};

int main(){
    vector<int> nums{7,5,6,8,3};
    Solution slu;

    int ret = slu.findGCD(nums);
    cout<<ret<<endl;

    return 0;
}